#define DEBUG
#include <cstdio>

using namespace std;

int calc(int suf[][10], int ) {
}

void solve(int o, int n, int a[][10]) {
  static bool book[11];
  for (int i=1; i<=n; i++) {
    if (!book[o]) {
      book[o] = true;
    }
  }
}

int main() {
  freopen("puzzle.in", "r", stdin);
  freopen("checker.out", "w", stdout);

  static int mat[10][10][10], w[10];
  int t;
  scanf("%d", &t);
  for (int ti=1; ti<=t; ti++) {
    int s, n;
    scanf("%d %d", &s, &n);
    for (int i=1; i<=s; i++) {
      scanf("%d", w+i);
      for (int j=1; j<=n; j++) {
	for (int k=1; k<=w[i]; k++) {
	  int x;
	  scanf("%d", &x);
	  mat[i][j][k] = mat[i][j-1][k]+mat[i][j][k-1]-mat[i][j-1][k-1]+x;
	}
      }
    }
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
